﻿using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mock1G3.BussinessLogic;
using Mock1G3.BaseEntities;

namespace Test_Mock1G3.TransferCash
{
    /// <summary>
    /// Summary description for TransferCash
    /// </summary>
    [TestClass]
    public class TransferCash
    {
        public TransferCash()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;
        TransferCashLogic transferLogic = new TransferCashLogic();
        Account account = new Account();

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest()
        {
            string str = "12345678901234";
            bool expect = true;
            bool actual = transferLogic.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest1()
        {
            AccountTransferLogic accountTransfer = new AccountTransferLogic();
            string str = "1234a89b01x23y";
            bool expect = false;
            bool actual = transferLogic.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest2()
        {
            string str = "";
            bool expect = false;
            bool actual = transferLogic.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest3()
        {
            string str = "#456732350";
            bool expect = false;
            bool actual = transferLogic.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest4()
        {
            string str = @"#@!~`$%^&*()+=-_{}?/\|";
            bool expect = false;
            bool actual = transferLogic.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckBalanceAmount
        /// </summary>
        [TestMethod]
        public void CheckBalanceAmountTest()
        {
            account.AccountNo = "9874575464";
            string amount = "530000";
            bool expect = true;
            bool actual = transferLogic.CheckBalanceAmount(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckBalanceAmount
        /// amount: not enough money to transfer
        /// AccountNo exist on DB
        /// </summary>
        [TestMethod]
        public void CheckBalanceAmountTest1()
        {
            account.AccountNo = "9874575464";
            string amount = "15000000";
            bool expect = false;
            bool actual = transferLogic.CheckBalanceAmount(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckBalanceAmount
        /// amount equal with balance on DB
        /// AccountNo exist on DB
        /// </summary>
        [TestMethod]
        public void CheckBalanceAmountTest2()
        {
            account.AccountNo = "9874575468";
            string amount = "1000000";
            bool expect = true;
            bool actual = transferLogic.CheckBalanceAmount(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckBalanceAmount
        /// amount
        /// AccountNo NOT exist on DB
        /// </summary>
        [TestMethod]
        public void CheckBalanceAmountTest3()
        {
            account.AccountNo = "98734575468";
            string amount = "530000";
            bool expect = false;
            bool actual = transferLogic.CheckBalanceAmount(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest()
        {
            string amount = "";
            bool expect = false;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount is special character
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest1()
        {
            string amount = @"`!@#$%^&*().,;:'\|<>?/";
            bool expect = false;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount is character
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest2()
        {
            string amount = "174am6";
            bool expect = false;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount is character
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest3()
        {
            string amount = "17$4am6";
            bool expect = false;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount greater Min = 0, amount lower Max = 30.000000
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest4()
        {
            string amount = "10000000";
            bool expect = true;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount greater Min = 0, amount = Max = 30.000000
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest5()
        {
            string amount = "30000000";
            bool expect = true;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount greater Min = 0, amount greater Max = 30.000000
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest6()
        {
            string amount = "31000000";
            bool expect = false;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckTransferLimit
        /// amount greater Min = 0, amount lower Max = 30.000000
        /// </summary>
        [TestMethod]
        public void CheckTransferLimitTest7()
        {
            string amount = "0";
            bool expect = true;
            bool actual = transferLogic.CheckTransferLimit(amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for TransferCash
        /// </summary>
        [TestMethod]
        public void TransferCashTest()
        {
            account.AccountNo = "9874575464";
            account.AccountNoRev = "9874575465";
            decimal amount = 500000;
            bool expect = true;
            bool actual = transferLogic.TransferCash(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for TransferCash
        /// </summary>
        [TestMethod]
        public void TransferCashTest1()
        {
            account.AccountNo = "9874575464";
            account.AccountNoRev = "9874575464";
            decimal amount = 100000;
            bool expect = true;
            bool actual = transferLogic.TransferCash(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for TransferCash
        /// </summary>
        [TestMethod]
        public void TransferCashTest3()
        {
            account.AccountNo = "9874575464";
            account.AccountNoRev = "9874575465";
            decimal amount = 152500;
            bool expect = true;
            bool actual = transferLogic.TransferCash(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for TransferCash
        /// </summary>
        [TestMethod]
        public void TransferCashTest4()
        {
            account.AccountNo = "9874575464";
            account.AccountNoRev = "9874575465";
            decimal amount = 152501;
            bool expect = true;
            bool actual = transferLogic.TransferCash(account, amount);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for WriteLog
        /// </summary>
        [TestMethod]
        public void WriteLogTest()
        {
            Log log = new Log();
            log.ATMID = 1;
            log.CardNo = "0123456789123456";
            log.LogDate = DateTime.Now;
            log.Amount = 152501;
            log.Detail = "Transfer Cash in other account";
            bool expect = true;
            bool actual = transferLogic.WriteLog(log);
            Assert.AreEqual(expect, actual);
        }
    }
}
